import java.math.BigInteger;
import java.util.HashMap;
import java.util.LinkedList;

class P10669_39643 {
	public static void main(String[] args) {
		
		String line = readLn();
		
		HashMap<Integer, BigInteger> m = new HashMap<Integer, BigInteger>();
		
		BigInteger three = new BigInteger("3");
		
		while (!"0".equals(line)) {
			
			BigInteger n = new BigInteger(line).subtract(BigInteger.ONE);
			String binary = n.toString(2);
			LinkedList<BigInteger> b = new LinkedList<BigInteger>();
			
			for (int k = 0; k < binary.length(); k++) {
				if (binary.charAt(k) == '1') {
					int i = binary.length() - k - 1;
					BigInteger value = m.get(i);

					if (value == null) {
						value = three.pow(i);
						m.put(i, value);
					}
					b.add(value);
				}
			}
			
			StringBuilder sb = new StringBuilder();
			
			for (int k = b.size() - 1; k >= 0; k--) {
				sb.append(b.get(k));
				
				if (k - 1 != -1) {
					sb.append(", ");
				}
			}
			
			if (sb.length() != 0) {
				System.out.println("{ " + sb.toString() + " }");	
			} else System.out.println("{ }");
			
			line = readLn();
		}
		
	}
	
	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuilder buffer = new StringBuilder();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString());
	}
	
}
